import request from '@/utils/request';
import Constants from '@/utils/constants';
import { stringify } from 'qs';

const serviceName = 'project';

export async function fetchProjectFileTreeApi(params) {
  return request(`${Constants.SERVICE_ROOT}/adapi/${serviceName}/fileTree?${stringify(params)}`);
}

export async function addFileInfoApi(params) {
  return request(`${Constants.SERVICE_ROOT}/adapi/${serviceName}/fileInfo`, {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function modifyFileInfoApi(params) {
  return request(`${Constants.SERVICE_ROOT}/adapi/${serviceName}/fileInfo`, {
    method: 'PUT',
    data: {
      ...params,
    },
  });
}

export async function delFileInfoApi(params) {
  return request(`${Constants.SERVICE_ROOT}/adapi/${serviceName}/fileInfo?${stringify(params)}`, {
    method: 'DELETE',
  });
}

export async function fetchFileInfoApi(params) {
  return request(`${Constants.SERVICE_ROOT}/adapi/${serviceName}/fileInfo?${stringify(params)}`);
}
